﻿using BookManage.BLL;
using BookManage.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BookManage
{
    public partial class frmSelectBorrow : Form
    {
        private BorrowAdmin borrowBLL = new BorrowAdmin();
        private DataTable dt = null;//存放查询结果，并给DataGridView drvBorrow提供数据
        Reader reader = frmLogin.reader;//登录窗口的reader对象
        public frmSelectBorrow()
        {
            InitializeComponent();
        }

        private void btnBack_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void ShowBorrowData()
        {
            dgvBorrow.DataSource = dt;
            foreach (DataColumn dc in dt.Columns)
            {
                dgvBorrow.Columns[dc.ColumnName].HeaderText = Borrow.ColumnTitle(dc.ColumnName);
            }
        }

        private void SelectBrw_Click(object sender, EventArgs e)
        {
            Borrow borrow = new Borrow();
            if (txtrdID.Text == "")
                MessageBox.Show("请输入书号！！！");
            else if (reader.rdID != Convert.ToInt32(txtrdID.Text))
                MessageBox.Show("您只能查看自己的借阅记录！！！");
            else
            {
                int rdID = Convert.ToInt32(txtrdID.Text);
                dt = borrowBLL.GetBorrow(rdID);
                ShowBorrowData();
            }
        }
    }
}
